module Enumerable
  def group_by
    out = Hash.new
	self.each do |x|
	  if out[yield(x)] == nil #If nothing for that key, add array
	    out[yield(x)] = [x] 
	  else #Else append to existing array
	     out[yield(x)] << x
	  end
	end
	out
  end
  
  def each_even
    self.each do |x|
	  yield(x) if x%2 == 0
	end
  end
  
  def each_grouped_by_first_letter
	self.group_by {|x| x[0,1].to_s }.each do |key, value|
		yield(key, value)
	end
  end
end